﻿using Abp.AutoMapper;
using Microsoft.EntityFrameworkCore;
using NetCore.Dtos;
using NetCore.Entities.Needs;
using NetCore.Interfaces;
using NetCore.Needs.Dtos;
using NetCore.Services;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Threading.Tasks;

namespace NetCore.Needs
{
    /// <summary>
    /// 需求
    /// </summary>
    [Description("需求")]
    public class NeedAttachmentAppService : BaseNetCoreAppService<NeedAttachment>, INeedAttachmentAppService
    {
        public NeedAttachmentAppService(INetCoreRepository<NeedAttachment> baseRepository) : base(baseRepository)
        {
        }

        public async Task<List<NeedAttachmentDto>> GetNeedAttachments(InputIdDto input)
        {
            var result = await BaseRepository.GetAll()
                .Where(m => m.NeedId == input.Id)
                .OrderByDescending(n => n.Order)
                .ToListAsync();
            return result.MapTo<List<NeedAttachmentDto>>();
        }
    }
}
